object WhileBasicDemo extends App {
  val maxBooks = 5
  var currentBooks = 0
  var continueBorrowing = true

  while (continueBorrowing && currentBooks < maxBooks){
    println(s"\n当前已借：$currentBooks 本，最多可借 $maxBooks 本")
    val wantToBorrow = if (currentBooks < 3)true else false

    if(wantToBorrow) {
      currentBooks += 1
      println(s"成功借阅 1 本书，现在共借 $currentBooks 本")
    } else {
      continueBorrowing = false
      println("用户选择停止借阅")
    }
  }
  if (currentBooks == maxBooks) {
    println (s"\n 已达到最大借阅数量（$maxBooks 本），无法继续借阅")
  }
  println(s"借阅流程结束，最终借阅 $currentBooks 本 ")
}
